-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vary
header for resource/files fetch operations
#4337
Conversation
Vary
header for resource/files fetch operationsVary
header for resource/files fetch operations
private val unauthorizedOrNotFound: PartialFunction[FileRejection, Boolean] = { | ||
case _: AuthorizationFailed | _: FileNotFound => true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's necessary to do this as in the ResourcesRoutes. Without the rejection on AuthorizationFailed it will inject the Vary header into the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better solution could be to improve the vary directive (as relying on rejection is not great) so as not to rely on respondWithHeaders
as it is based on mapResponse
:
def mapResponse(f: HttpResponse => HttpResponse): Directive0 =
mapRouteResultPF { case RouteResult.Complete(response) => RouteResult.Complete(f(response)) }
We could have something like:
def mapSuccessResponse(f: HttpResponse => HttpResponse): Directive0 =
mapRouteResultPF { case RouteResult.Complete(response) if response.status.isSuccess => RouteResult.Complete(f(response)) }
And build the vary directive on top of that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better yes
@@ -110,6 +110,13 @@ trait DeltaDirectives extends UriDirectives { | |||
} | |||
} | |||
|
|||
/** Injects a `Vary: Accept,Accept-Encoding` into the response */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeltaDirectives
is temporarily duplicated :)
9b68d48
to
6d323cc
Compare
Closes #4300
Closes #4299